#pragma once
#include <SFML/Graphics/Drawable.hpp>
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/RenderStates.hpp>

#include "point.hpp"
#include "move.hpp"

#define LINE_CELLS			8
#define GP_CELL_WIDTH		32
#define GP_CELL_HEIGHT		GP_CELL_WIDTH
#define GP_BORDER_THICK		3
#define GP_LINE_THICK		2
#define GP_WIDTH			(GP_CELL_WIDTH * LINE_CELLS + GP_BORDER_THICK * 2 + GP_LINE_THICK * (LINE_CELLS - 1))
#define GP_HEIGHT			(GP_CELL_HEIGHT * LINE_CELLS + GP_BORDER_THICK * 2 + GP_LINE_THICK * (LINE_CELLS - 1))

#define CHESS_MARGIN		5
#define CHESS_RADIUS		(GP_CELL_WIDTH / 2) - CHESS_MARGIN

#define GP_BACK_COLOR		0xffca09ff	// RGBA(255, 200, 9, 0)
#define GP_BODR_COLOR		0x744730ff	// RGBA(116, 71, 48, 0)
#define GP_LINE_COLOR		0xb9b9b9ff	// RGBA(185, 185, 185, 0)

#define CHESS_BLACK			0x000000ff
#define CHESS_WHITE			0xffffffff

namespace othello {

	typedef enum {
		BLACK = -1,
		WHITE = 1
	} Player;

	class OthelloGame final : public sf::Drawable {
		int m_map[LINE_CELLS][LINE_CELLS];
		std::vector<Point<int>> m_dir;
		void draw_map(sf::RenderTarget&) const;
		size_t get_possible_moves(const Player, std::vector<Move>&) const;

		static void draw_chess(sf::RenderTarget&, const Point<int>& point, const Player);
		static void draw_pad(sf::RenderTarget&);
		static Point<float> board_to_screen(const Point<int>&);
		static Point<int> screen_to_board(const Point<float>&);
	public:
		OthelloGame();
		void initialize();
	protected:
		void draw(sf::RenderTarget&, sf::RenderStates) const override;
	};

}